<template>
  <LdbpPage
    pageName="xcsz"
    zh_name="乡村善治"
    :rankList_title="rankList_title"
    :rankList_th="rankList_th"
    :rankList_4="rankList_4"
    :rankList_6="rankList_6"
    :rankList_8="rankList_8"
    :info="info"
  ></LdbpPage>
</template>

<script>
import axios from 'axios'
import LdbpPage from '../../components/LdbpPage'

export default {
  name: 'Xcsz',
  components: { LdbpPage },
  data() {
    return {
      info: '乡村善治通过农村人居住环境长效管理比拼，乡村治理智治比拼，以狠抓环境，全面推进乡村钉，全面推进‘钉公分’，开展善治村建设，推广清廉乡村智慧管家，规范村社检察联络站运行，推动村级工程，深化乡村建设等措施，让干净整洁成为建德大地的第一感官，推动示范教育力度，强化引领带动作用。',
      rankList_title: ['农村人居环境长效管理榜', '乡村治理“智治”', '清廉乡村建设'],
      rankList_th: [
        ['', '', '总分'],
        ['', '', '总分'],
        ['', '', '总分']
      ],
      rankList_4: [],
      rankList_6: [],
      rankList_8: [],
    };
  },
  mounted() {
    // 四月
    this.request('/getEnvManageList', '4', 0) // 农村人居环境长效管理榜
    this.request('/getVillageGovernList', '4', 1) // 乡村治理“智治”
    this.request('/getDeeIntegrityList', '4', 2) // 清廉乡村建设
    // 六月
    this.request('/getEnvManageList', '6', 0)
    this.request('/getVillageGovernList', '6', 1)
    this.request('/getDeeIntegrityList', '6', 2)
    // 八月
    this.request('/getEnvManageList', '8', 0)
    this.request('/getVillageGovernList', '8', 1)
    this.request('/getDeeIntegrityList', '8', 2)
  },
  methods: {
    request(url, month, index) {
      // 月份参数处理
      let newMonth;
      if (month === '6') {
        newMonth = '5-6'
      }
      if (month === '8') {
        newMonth = '7'
      }
      axios({
        method: 'post',
        url: 'https://lst.jiande.gov.cn:8443/competition_jiande/VillageGovern' + url,
        headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
        params: { month: newMonth || month }
      })
        .then(({data: {data}}) => {
          console.log('res', month, data);
          if (data) {
            this['rankList_' + month][index] = data
          }
        })
        .catch(err => {
          console.log('err', err);
        });
    }
  }
};
</script>